#include "processbar.h"

double bandwidth = 1024*1024*2.0;//带宽
void download(double filesize,callback_t cb)
{
  double current=0.0;//已下载量
  
  printf("download begin\n");

  while(current<=filesize)
  {
    cb(filesize,current);
    current+=bandwidth;
    usleep(100000);
  }

  printf("\ndownload done, filesize: %lf\n",filesize);
  
}

int main()
{
  //ForTest();
  //ProcBar();
  //ProcBar(100,50);
  //ProcBar(100,70);
  //ProcBar(100,90);
  download(10*1024*1024,ProcBar);
  download(50*1024*1024,ProcBar);
  download(20*1024*1024,ProcBar);
  download(30*1024*1024,ProcBar);
  printf("\n");

  return 0;
}
